﻿using System.Diagnostics;

using VSTalk.Model;

namespace VSTalk.Engine.Core.Disco.Caps
{
    [DebuggerDisplay("EntityJid = {EntityJid}")]
    public class CapsSource
    {
        public Client Client { get; set; }
        public string EntityJid { get; set; }

        public CapsSource(Client client, string entityJid)
        {
            Client = client;
            EntityJid = entityJid;
        }

        protected bool Equals(CapsSource other)
        {
            return Equals(Client, other.Client) && string.Equals(EntityJid, other.EntityJid);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((CapsSource) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return ((Client != null ? Client.GetHashCode() : 0) * 397) ^ (EntityJid != null ? EntityJid.GetHashCode() : 0);
            }
        }

        public static bool operator ==(CapsSource left, CapsSource right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(CapsSource left, CapsSource right)
        {
            return !Equals(left, right);
        }
    }
}